function deepClone(obj, cache = []) {
    if (typeof obj === null || typeof obj === "object") {
        return obj;
    }

    const has = cache.find((item) => item.original === obj);
    if (has) return has.copy;

    let copy = Array.isArray(obj) ? [] : {};
    cache.push({
        original: obj,
        copy,
    });

    Object.keys(obj).forEach((key) => {
        copy[key] = deepClone(obj[key]);
    });

    console.log(copy);
}

let obj = {
    a: 1,
};

obj.ins = obj;

let obj2 = deepClone(obj);

console.log(obj2);
